home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / vol11n06.zip / CLRPRI.BAS < prev    next >
BASIC Source File  |  1991-03-28  |  2KB  |  43 lines

  1. 'CLRPRINT.BAS - graphics printing routine accepts a background color
  2.  
  3. '$INCLUDE: 'QB.BI'      'this defines the RegTypeX TYPE variable
  4.  
  5. DECLARE SUB ColorPrint (text$, row%, col%, fc%, bc%)
  6. DIM SHARED Registers AS RegTypeX
  7.  
  8. SCREEN 9
  9.  
  10. FOR i = 9 TO 210 STEP 10    'draw ellipses to show it's graphics mode
  11.   Clr = Clr + 1
  12.   CIRCLE (310, i), i, Clr MOD 16, , , .6
  13. NEXT
  14.  
  15. CALL ColorPrint(" ColorPrint - Microsoft QuickBasic ", 3, 23, 4, 7)
  16. CALL ColorPrint(" Graphics text with a background color! ", 5, 20, 7, 1)
  17.  
  18. FOR bc% = 0 TO 15           'display all possible color combinations
  19.   FOR fc% = 0 TO 15
  20.     CALL ColorPrint(HEX$(fc%), 8 + bc%, 32 + fc%, fc%, bc%)
  21.   NEXT
  22. NEXT
  23.  
  24. SUB ColorPrint (text$, row%, col%, fc%, bc%) STATIC
  25.  
  26.     c$ = STRING$(LEN(text$), 219)   'create a string of solid characters
  27.  
  28.     Registers.ax = &H1300           'video service 13h, subfunction 0
  29.     Registers.bx = bc%              'BH = page (0), BL = color
  30.     Registers.cx = LEN(text$)       'CX = string length
  31.     Registers.dx = 256 * (row% - 1) + (col% - 1)  'DH = row, DL = column
  32.     Registers.es = VARSEG(c$)       'ES = string data segment
  33.     Registers.bp = SADD(c$)         'BP = string address
  34.     CALL InterruptX(&H10, Registers, Registers)   'call the BIOS to print it
  35.  
  36.     Registers.bx = (fc% XOR bc%) + &H80 'BL = color, +&H80 means use XOR
  37.     Registers.es = VARSEG(text$)    'ES = string data segment
  38.     Registers.bp = SADD(text$)      'BP is the string address
  39.     CALL InterruptX(&H10, Registers, Registers)   'call the BIOS
  40.  
  41. END SUB
  42.  
  43.